/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.schedule.core.domain.action;


import cn.hutool.core.bean.BeanUtil;
import info.peigen.hotpot.component.schedule.core.domain.ScheduleNode;
import info.peigen.hotpot.component.schedule.core.repository.entity.ScheduleNodeEntity;
import info.peigen.hotpot.component.schedule.facade.command.result.info.ScheduleNodeManageInfo;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <b>(ScheduleNodeConvertor)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2022/12/28
 */
public class ScheduleNodeConvertor {
    public static ScheduleNodeEntity convert(ScheduleNode domain) {
        return BeanUtil.copyProperties(domain, ScheduleNodeEntity.class);
    }

    public static ScheduleNode convert(ScheduleNodeEntity entity) {
        return BeanUtil.copyProperties(entity, ScheduleNode.class);
    }

    public static ScheduleNodeManageInfo convertToInfo(ScheduleNode domain) {
        return BeanUtil.copyProperties(domain, ScheduleNodeManageInfo.class);
    }

    public static ScheduleNodeManageInfo convertToInfo(ScheduleNodeEntity entity) {
        return BeanUtil.copyProperties(entity, ScheduleNodeManageInfo.class);
    }

    public static List<ScheduleNodeManageInfo> convertToInfo(List<ScheduleNodeEntity> entities) {
        return entities.stream().map(each -> BeanUtil.copyProperties(each, ScheduleNodeManageInfo.class)).collect(Collectors.toList());
    }
}